package com.erpoa.mapper;

import com.erpoa.entity.MgUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author chenjimin
 * @Title: PdaLoginServiceMapper
 * @ProjectName oaerp
 * @Description: TODO
 * @date 2020/9/114:40
 */
@Mapper
public interface PdaLoginServiceMapper {
    /**
     * @param scode
     * @return
     */
    MgUser selectUserBysCode(@Param("scode") String scode);

    /**
     * @param scode
     * @return
     */
    List<Integer> selectPerssionBysCode(@Param("scode") String scode);

    /**
     * @param deviceID
     * @return
     */
    Integer getPDAStatus(@Param("deviceID") String deviceID);

    @Update(" MERGE INTO mg_pdavnholast H USING (SELECT #{deviceid} AS PDADEVICEID,#{version} AS VERSION,#{sCode} AS HRNO FROM dual ) J " +
            " ON (H.PDADEVICEID = J.PDADEVICEID) " +
            " WHEN MATCHED THEN " +
            " UPDATE SET H.VERSION=J.VERSION,H.HRNO=J.HRNO,H.LOGINTIME=SYSDATE" +
            " WHEN NOT MATCHED THEN" +
            " INSERT(H.PDADEVICEID,H.VERSION,H.HRNO,H.LOGINTIME) VALUES(J.PDADEVICEID,J.VERSION,J.HRNO,SYSDATE)  ")
    Integer updateorInsertPdaVersion(@Param("deviceid") String deviceid, @Param("version") String version, @Param("sCode") String sCode);
}
